<?php

namespace App\Http\Resources\Backend;

use Illuminate\Http\Resources\Json\Resource;

/**
 * Class BookOrderResource
 * @package App\Http\Resources\Backend
 */
class BookOrderResource extends Resource
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'is_calculate' => $this->is_calculate,
            'rule_name' => $this->rule_name,
            'status_label' => $this->status_label,
            'type_label' => $this->type_label,
            'eat_date' => $this->eat_date,
            'eat_type' => $this->eat_type,
            'school_name' => $this->school_name,
            'rule' => new BookRuleResource($this->whenLoaded('rule')),
            'user' => new UserResource($this->whenLoaded('user')),
            'eat_name' => $this->eat_name,
            'eat_phone' => $this->eat_phone,
            'price_rule' => $this->price_rule,
            'user_id' => $this->user_id,
            'book_rule_id' => $this->book_rule_id,
            'is_auto' => $this->is_auto,
            'school_id' => $this->school_id,
            'origin_price' => $this->origin_price,
            'pay_price' => $this->pay_price,
            'is_calculated' => $this->is_calculated,
            'status' => $this->status,
            'type' => $this->type,
            'is_review' => $this->is_review,
            'making_at' => $this->making_at,
            'finished_at' => $this->finished_at,
            'canceled_at' => $this->canceled_at,
            'created_at' => $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null
        ];
    }
}
